package work20241223;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author zdl
 * @date 2024/12/23
 */
public class Demo3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                for (int i = 0; i < 100; i++) {
                    System.out.println("线程1:" + i);
                }
                return "hhhhh";
            }
        });
        new Thread(futureTask).start();
        futureTask.get();
    }
}
